package com.weiyuwqj.controller.notice;

import com.weiyuwqj.api.service.*;
import com.weiyuwqj.controller.xianfeng.Collect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

/**
 * 统一处理支付的异步回调
 * Created by hello on 2016/8/16.
 */
@Controller
public class PaymentNoticeController {
    private static Logger log = Logger.getLogger("PaymentNoticeController");

    @Autowired
    BasItemService itemService;

    @Autowired
    BusAccountCashService accountCashService;

    @Autowired
    BusAccountRechargeService accountRechargeService;

    @Autowired
    BusVerifyLogService verifyLogService;

    @Autowired
    BusAccountBankService accountBankService;

    @Autowired
    BasExperiencedGoldService experiencedGoldService;


    @Autowired
    BasUserInviteIncomeService inviteIncomeService;

    @Autowired
    BusBonusRebateService bonusRebateService;

    @Autowired
    BusAccountService accountService;

    @Autowired
    Collect collect;
/*
    @Autowired
    private PaymentNoticeService paymentNoticeService;

    @Autowired
    SignKeyService signKeyService;*/

    @Autowired
    BasUserInviteService inviteService;
    @Autowired
    SysConfigTicketRuleService configTicketRuleService;


    //标的报备的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/createBid")
    public Object CreateBidNotice(@RequestParam("merchantId") String merchantId,//商户号
                                  @RequestParam("bidId") String bidId,//标的id
                                  @RequestParam("bidStatus") String bidStatus,//标的状态:W= 等待审核中,II = 投资中,GI=放款中,GD=已放款,CI=流标中,CD=已流标
                                  @RequestParam("bankAuditStatus") String bankAuditStatus,//银行标的审核状态 S = 成功 F = 失败
                                  @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map<String, String> returnMap = new HashMap<String, String>();
        returnMap.put("merchantId", merchantId + "");
        returnMap.put("bidId", bidId + "");
        returnMap.put("bidStatus", bidStatus + "");
        returnMap.put("bankAuditStatus", bankAuditStatus + "");

return null;
/*
        Map map = new HashMap();
        if (signKeyService.toVerify(signature, returnMap)) {
            if ("II".equalsIgnoreCase(bidStatus) && ("s".equalsIgnoreCase(bankAuditStatus) || "n".equalsIgnoreCase(bankAuditStatus))) {
                Integer itemId = Integer.parseInt(bidId);
                //成功

                //itemService.firstVerifySuccess(itemId);

//                itemService.firstVerifySuccess(itemId);

                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                collect.collect(null,returnMap,null,null,null,null,null,20,null,null);
                return map;
            } else {
                Integer itemId = Integer.parseInt(bidId);
                itemService.updateItemIsalive(0, itemId);
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                collect.collect(null,returnMap,null,null,null,null,null,20,null,null);
                return map;
            }
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,null,null,20,null,0);
            return map;
        }*/
    }

    //标的更新的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/updateBid", method = RequestMethod.POST)
    public Object UpdateBidNotice(@RequestParam("bizType") String bizType,//业务类型
                                  @RequestParam("bidId") String bidId,//订单号
                                  @RequestParam("bidStatus") String bidStatus,//标的状态 S = 成功 F = 失败
                                  @RequestParam("bankAuditStatus") String bankAuditStatus,//银行标的审核状态 S = 成功 F = 失败
                                  @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("bidId", bidId);
        returnMap.put("bidStatus", bidStatus);
        returnMap.put("bankAuditStatus", bankAuditStatus);
        Map map = new HashMap();
        if (/*signKeyService.toVerify(signature, returnMap)*/1==1) {
            if ("s".equalsIgnoreCase(bidStatus) && "s".equalsIgnoreCase(bankAuditStatus)) {
                //成功
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                collect.collect(null,returnMap,null,null,null,bidId,null,20,null,1);
                return map;
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                collect.collect(null,returnMap,null,null,null,bidId,null,20,null,0);
                return map;
            }
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,bidId,null,20,null,0);
            return map;
        }

    }

    //流标的异步回调
//    @ResponseBody
//    @RequestMapping(value = "/pay/notice/bidCancel", method = RequestMethod.POST)
//    public Object BidCancelNotice(@RequestParam("orderId") String orderId,//订单号
//                                  @RequestParam("bidId") String bidId,//标的
//                                  @RequestParam("status") String status,//返回状态 S = 成功 F = 失败
//                                  @RequestParam("signature") String signature,//签名，附加说明
//                                  @RequestParam("merchantId") String merchantId//商户号
//    ) {
//        Map returnMap = new HashMap();
//
//        returnMap.put("orderId", orderId);
//        returnMap.put("bidId", bidId);
//        returnMap.put("status", status);
//        returnMap.put("merchantId", merchantId);
////        log.info("cancel====================" + signKeyService.toVerify(signature, returnMap));
//        log.info("orderId=================" + orderId);
//        Map map = new HashMap();
//        if (signKeyService.toVerify(signature, returnMap)) {
//            if ("F".equalsIgnoreCase(status)) {
//                map.put("respCode", "02");
//                map.put("respMsg", "失败");
//                collect.collect(null, returnMap, null, null, null, orderId, null, 20, null, 0);
//                return map;
//            } else {
//                itemService.cancelCallBack(new Integer(bidId));
//                map.put("respCode", "00");
//                map.put("respMsg", "成功");
//                collect.collect(null, returnMap, null, null, null, orderId, null, 20, null, 1);
//                return map;
//            }
//        } else {
//            map.put("respCode", "01");
//            map.put("respMsg", "验签失败");
//            collect.collect(null,returnMap,null,null,null,orderId,null,20,null,0);
//            return map;
//        }
//    }

    //放款的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/bidGrant", method = RequestMethod.POST)
    public Object BidGrantNotice(@RequestParam("bizType") String bizType,//业务类型,固定值5001
                                 @RequestParam("orderId") String orderId,//订单ID
                                 @RequestParam("status") String status,//返回状态 S = 成功 F = 失败
                                 @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map returnMap = new HashMap();

        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        log.info("orderId===========" + orderId);
        log.info("signature===========" + signature);
        Map map = new HashMap();
        /*if (signKeyService.toVerify(signature, returnMap)) {
            //判断先锋订单是否已经处理
            synchronized (PaymentNoticeController.class){
                BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);
                if (order.getStatus() != 2) {
                    map.put("respCode", "00");
                    map.put("respMsg", "已受理");
                    return map;
                }
            }

            //修改先锋订单表
            Map param = new HashMap();
            param.put("oldStatus", 2);
            param.put("orderNo", orderId);
            param.put("paramJson", JsonUtils.toJson(returnMap));
            if ("F".equalsIgnoreCase(status)) {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                itemService.updateItemStatus(ItemStatus.FULL_AUDIT, ItemStatus.THIRD_FULL_AUDIT, new Integer(orderId));
                param.put("newStatus", 0);
            } else {
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                String itemId = orderId.substring(10, orderId.length());
//                itemService.fullVerifySuccess(new Integer(itemId));

                param.put("newStatus", 1);
            }
            collect.collect(null, returnMap, null, null, null, orderId, null, 4, null, (Integer) param.get("newStatus"));
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,4,null,0);
            return map;
        }*/
        return null;
    }

    //还款的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/bidRepay", method = RequestMethod.POST)
    public Object BidRepayNotice(@RequestParam("merchantId") String merchantId,//业务类型
                                 @RequestParam("orderId") String orderId,//订单ID
                                 @RequestParam("status") String status,//返回状态 S = 成功 F = 失败
                                 @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map map = null;//paymentNoticeService.bidRepayNotice(merchantId, orderId, status, signature);
        return map;
    }

    //提现的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/withdraw", method = RequestMethod.POST)
    public Object WithdrawNotice(@RequestParam("bizType") String bizType,//业务类型,固定值2001
                                 @RequestParam("orderId") String orderId,//订单ID
                                 @RequestParam("status") String status,//返回状态 S = 成功 F = 失败
                                 @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
        /*log.info("cash===================" + signKeyService.toVerify(signature, returnMap));
        log.info("cash===================oderid=" + orderId);
        if (signKeyService.toVerify(signature, returnMap)) {
            //判断先锋订单是否已经处理
            BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);

            if (order == null || order.getStatus() != 2) {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                return map;
            }
            //修改先锋订单
            Map param = new HashMap();
            param.put("paramJson", JsonUtils.toJson(returnMap));
            param.put("oldStatus", 2);
            param.put("orderNo", orderId);

            if ("s".equalsIgnoreCase(status)) {
                //成功
                accountCashService.updateBusAccountCashStatus(orderId, 2, 1, IpUtils.get());
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                param.put("newStatus", 1);
            } else {
                accountCashService.updateBusAccountCashStatus(orderId, 2, 0, IpUtils.get());
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                param.put("newStatus", 0);
            }
            collect.collect(null,returnMap,null,null,null,orderId,null,2,null,(Integer)param.get("newStatus"));
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,2,null,0);
            return map;
        }*/
        return map;

    }

    //绑卡的后台异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/admin/createCard", method = RequestMethod.POST)
    public Object AdminCreateCardNotice(@RequestParam("merchantId") String merchantId,//商户号
                                        @RequestParam("userId") String userId,//P2P用户ID
                                        @RequestParam("bankCode") String bankCode,//银行编码
                                        @RequestParam("amount") String amount,//	金额
                                        @RequestParam("orderId") String orderId,//外部订单号（由金服生成的）
                                        @RequestParam("bankCardNo") String bankCardNo,//银行卡
                                        @RequestParam("bankName") String bankName,//银行名称
                                        @RequestParam(value = "brankId", required = false) String brankId,//分支行id（联行号）
                                        @RequestParam("transTime") String transTime,//时间戳
                                        @RequestParam("signature") String signature,//签名结果
                                        @RequestParam(value = "province", required = false) String province,
                                        @RequestParam(value = "city", required = false) String city
    ) {
        Map returnMap = new HashMap();
        returnMap.put("merchantId", merchantId);
        returnMap.put("userId", userId);
        returnMap.put("bankCode", bankCode);
        returnMap.put("amount", amount);
        returnMap.put("orderId", orderId);
        returnMap.put("bankCardNo", bankCardNo);
        returnMap.put("bankName", bankName);
        if (brankId == null) {
            returnMap.put("brankId", "");
        } else {
            returnMap.put("brankId", brankId);
        }
        returnMap.put("transTime", transTime);
        if (province == null) {
            returnMap.put("province", "");
        } else {
            returnMap.put("province", province);
        }
        if (city == null) {
            returnMap.put("city", "");
        } else {
            returnMap.put("city", city);
        }/*
        log.info("signature==================" + signature);
        log.info("====================" + signKeyService.toVerify(signature, returnMap));
        log.info("returnMap====================" + returnMap);
        Map map = new HashMap();
        if (signKeyService.toVerify(signature, returnMap)) {
            map.put("respCode", "00");
            map.put("respMsg", "成功");
            List list = accountBankService.getBankByUserId(Integer.parseInt(userId));
            if (list.size() == 0) {
                BusAccountBank bank = new BusAccountBank();
                bank.setCardNo(bankCardNo);
                bank.setUserId(Integer.parseInt(userId));
                bank.setAddip(IpUtils.get());
                bank.setAddtime(new Date());
                bank.setStatus(1);
                bank.setBankCode(bankCode);
                bank.setBankName(bankName);
                accountBankService.save(bank);
                //发送绑卡成功提示短信
                paymentNoticeService.sendBindCardSms(userId,bankName);
                //实名邀请人奖励
                BasUserInviteVo userInvite = inviteService.getOneByInviteId(Integer.parseInt(userId));
                if(userInvite !=null){
                    TicketParamEntity realNameParam = new TicketParamEntity();
                    realNameParam.setNid(Constants.realname_invite_nid);
                    realNameParam.setUserId(userInvite.getUserId());
                    realNameParam.setInviteId(Integer.parseInt(userId));
                    configTicketRuleService.addTicket(realNameParam);
                }
            }
            collect.collect(null,returnMap,userId,null,amount,orderId,null,21,null,1);
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,userId,null,amount,orderId,null,21,null,0);
            return map;
        }*/
        return null;

    }


    //体验金回调地址
    @ResponseBody
    @RequestMapping(value = "/pay/notice/experiencedGold", method = RequestMethod.POST)
    public Object experiencedGoldNotice(@RequestParam("bizType") String bizType,             //业务类型,固定值8000
                                        @RequestParam("orderId") String orderId,             //订单ID
                                        @RequestParam("status") String status,               //状态,S = 成功 F = 失败
                                        @RequestParam("signature") String signature          //签名
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
        log.info("experiencedGold==========================" + orderId);
        log.info("experiencedGold======================status" + status);
      /*  if (signKeyService.toVerify(signature, returnMap)) {
            //判断先锋订单是否已经处理
            BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);
            if (order == null) {
                map.put("respCode", "00");
                map.put("respMsg", "无此订单");
                return map;
            }
            if (order.getStatus() != 2) {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                return map;
            }
            if ("s".equalsIgnoreCase(status)) {
                //成功
                experiencedGoldService.dealAmount(orderId);
                returnMap.put("respCode", "00");
                returnMap.put("respMsg", "成功");
                collect.collect(null,returnMap,null,null,null,orderId,null,7,null,1);
                return returnMap;
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                collect.collect(null,returnMap,null,null,null,orderId,null,7,null,0);
                return map;
            }
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,7,null,0);
            return map;
        }*/
      return map;
    }

    //提成奖励回调地址
    @ResponseBody
    @RequestMapping(value = "/pay/notice/doInviteIncome", method = RequestMethod.POST)
    public Object doInviteIncomeNotice(@RequestParam("bizType") String bizType,             //业务类型,固定值8000
                                       @RequestParam("orderId") String orderId,             //订单ID
                                       @RequestParam("status") String status,               //状态,S = 成功 F = 失败
                                       @RequestParam("signature") String signature          //签名
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
        /*log.info("doInviteIncome==========================" + signKeyService.toVerify(signature, returnMap));
        log.info("doInviteIncome==========================" + orderId);
        if (signKeyService.toVerify(signature, returnMap)) {
            if ("s".equalsIgnoreCase(status)) {
                //成功
                inviteIncomeService.dealAmount(orderId);
                returnMap.put("respCode", "00");
                returnMap.put("respMsg", "成功");
                collect.collect(null,returnMap,null,null,null,orderId,null,22,null,1);
                return returnMap;
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                collect.collect(null,returnMap,null,null,null,orderId,null,22,null,0);
                return map;
            }
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,22,null,0);
            return map;
        }*/
        return map;
    }

    //企业会员开户回调地址
    @ResponseBody
    @RequestMapping(value = "/pay/notice/createEnterprise", method = RequestMethod.POST)
    public Object createEnterprise(@RequestParam("merchantId") String merchantId,//商户号 （此回调为充值的回调：有些认证类型需要扣除用户银行卡一定的金额，认证成功后需要给用户账户加上这笔金额。不扣除金额的认证不通知商户。）
                                   @RequestParam("userId") String userId,        //P2P用户ID
                                   @RequestParam("orderId") String orderId,      //外部订单号（由金服生成的）
                                   @RequestParam("status") String status,        //返回状态：S-成功；F-失败
                                   @RequestParam("signature") String signature   //签名结果
    ) {
        Map returnMap = new HashMap();
        returnMap.put("merchantId", merchantId);
        returnMap.put("userId", userId);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
        if (/*signKeyService.toVerify(signature, returnMap)*/1==1) {
            if ("s".equalsIgnoreCase(status)) {
                //成功
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                Map param = new HashMap();
                param.put("newStatus", 1);
                param.put("oldStatus", 2);
                param.put("userId", userId);
                accountBankService.updateBankStatus(param);
                collect.collect(null,returnMap,userId,null,null,orderId,null,23,null,1);
            } else {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                Map param = new HashMap();
                param.put("newStatus", 0);
                param.put("oldStatus", 2);
                param.put("userId", userId);
                accountBankService.updateBankStatus(param);
                collect.collect(null,returnMap,userId,null,null,orderId,null,23,null,0);
            }

            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,userId,null,null,orderId,null,23,null,0);
            return map;
        }
    }

    //提前还款的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/bidPrepayment", method = RequestMethod.POST)
    public Object bidPrepayment(@RequestParam("merchantId") String merchantId,//业务类型
                                @RequestParam("orderId") String orderId,//订单ID
                                @RequestParam("status") String status,//返回状态 S = 成功 F = 失败
                                @RequestParam("signature") String signature//签名，附加说明
    ) {
        Map map = null;//paymentNoticeService.bidPrepayment(merchantId,orderId,status,signature);
        return map;
    }

    //违约金的异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/contract", method = RequestMethod.POST)
    public Object contract(@RequestParam("bizType") String bizType,             //业务类型,固定值8000
                           @RequestParam("orderId") String orderId,             //订单ID
                           @RequestParam("status") String status,               //状态,S = 成功 F = 失败
                           @RequestParam("signature") String signature          //签名
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
       /* if (signKeyService.toVerify(signature, returnMap)) {
                //判断先锋订单是否已经处理
                BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);
                if (order.getStatus() != 2) {
                    map.put("respCode", "00");
                    map.put("respMsg", "已受理");
                    return map;
                }
            Map param = new HashMap();
            param.put("orderNo", orderId);
            param.put("paramJson", JsonUtils.toJson(returnMap));
            param.put("oldStatus", 2);
            if ("s".equalsIgnoreCase(status)) {
                //成功
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                param.put("newStatus", 1);
                //修改违约金接口
                String itemId = orderId.substring(10, orderId.length());
                itemService.contractCallBack(Integer.parseInt(itemId), orderId);
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                param.put("newStatus", 0);
            }
            collect.collect(null,returnMap,null,null,null,orderId,null,24,null,(Integer)param.get("newStatus"));
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,24,null,0);
            return map;
        }*/
       return map;
    }

    //调账回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/checkBalance", method = RequestMethod.POST)
    public Object checkBalance(@RequestParam("bizType") String bizType,             //业务类型,固定值8000
                               @RequestParam("orderId") String orderId,             //订单ID
                               @RequestParam("status") String status,               //状态,S = 成功 F = 失败
                               @RequestParam("signature") String signature          //签名
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
       /* if (signKeyService.toVerify(signature, returnMap)) {
            //判断先锋订单是否已经处理
            BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);
            if (order.getStatus() != 2) {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                return map;
            }
            Map param = new HashMap();
            param.put("orderNo", orderId);
            param.put("paramJson", JsonUtils.toJson(returnMap));
            param.put("oldStatus", 2);
            if ("s".equalsIgnoreCase(status)) {
                //成功
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                param.put("newStatus", 1);
                bonusRebateService.changeNotice(orderId, 2, 1);
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                param.put("newStatus", 0);
                bonusRebateService.changeNotice(orderId, 2, 0);
            }
            collect.collect(null,returnMap,null,null,null,orderId,null,25,null,(Integer)param.get("newStatus"));
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,25,null,0);
            return map;
        }*/
       return map;
    }

    //转账回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/transfer", method = RequestMethod.POST)
    public Object transfer(@RequestParam("bizType") String bizType,             //业务类型,固定值8000
                           @RequestParam("orderId") String orderId,             //订单ID
                           @RequestParam("status") String status,               //状态,S = 成功 F = 失败
                           @RequestParam("signature") String signature          //签名
    ) {
        Map returnMap = new HashMap();
        returnMap.put("bizType", bizType);
        returnMap.put("orderId", orderId);
        returnMap.put("status", status);
        Map map = new HashMap();
       /* if (signKeyService.toVerify(signature, returnMap)) {
            //判断先锋订单是否已经处理
            BusXfOrder order = xfOrderServer.getXfOrderByOrderNo(orderId);
            if (order.getStatus() != 2) {
                map.put("respCode", "00");
                map.put("respMsg", "已受理");
                return map;
            }
            Map param = new HashMap();
            param.put("orderNo", orderId);
            param.put("paramJson", JsonUtils.toJson(returnMap));
            param.put("oldStatus", 2);
            if ("s".equalsIgnoreCase(status)) {
                //成功
                map.put("respCode", "00");
                map.put("respMsg", "成功");
                param.put("newStatus", 1);
                bonusRebateService.transferNotice(orderId, 2, 1);
            } else {
                map.put("respCode", "02");
                map.put("respMsg", "失败");
                param.put("newStatus", 0);
                bonusRebateService.transferNotice(orderId, 2, 0);
            }
            collect.collect(null,returnMap,null,null,null,orderId,null,26,null,(Integer)param.get("newStatus"));
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,null,null,null,orderId,null,26,null,0);
            return map;
        }*/

       return map;
    }

    //查询用户总资产
    @ResponseBody
    @RequestMapping(value = "/pay/notice/getAssetsAmt", method = RequestMethod.POST)
    public Object getAssetsAmt(@RequestParam("userId") String userId,//业务类型,固定值8000
                               @RequestParam("merchantId") String merchantId//商户号
    ) {
        return null;// accountService.getAssetsAmt(userId,merchantId);

    }

    //用户更换银行卡异步回调
    @ResponseBody
    @RequestMapping(value = "/pay/notice/updateCard", method = RequestMethod.POST)
    public Object updateCardNotice(@RequestParam("merchantId") String merchantId,//商户号
                                        @RequestParam("userId") String userId,//P2P用户ID
                                        @RequestParam("outOrderId") String outOrderId,//外部订单号
                                        @RequestParam("authAmount") String authAmount,//金额
                                        @RequestParam("cardNo") String cardNo,//银行卡
                                        @RequestParam("bankCode") String bankCode,//银行编码
                                        @RequestParam("bankName") String bankName,//银行名称
                                        @RequestParam(value= "province", required = false) String province,//分支行省
                                        @RequestParam(value= "city", required = false) String city,//分支行市
                                        @RequestParam(value = "brankId", required = false) String brankId,//分支行id（联行号）
                                        @RequestParam("theTime") String theTime,//时间戳
                                        @RequestParam("signature") String signature//签名结果
    ) {
        Map returnMap = new HashMap();
        returnMap.put("merchantId", merchantId);
        returnMap.put("userId", userId);
        returnMap.put("bankCode", bankCode);
        returnMap.put("authAmount", authAmount);
        returnMap.put("outOrderId", outOrderId);
        returnMap.put("cardNo", cardNo);
        returnMap.put("bankName", bankName);
        if (brankId == null) {
            returnMap.put("brankId", "");
        } else {
            returnMap.put("brankId", brankId);
        }
        returnMap.put("theTime", theTime);
        if (province == null) {
            returnMap.put("province", "");
        } else {
            returnMap.put("province", province);
        }
        if (city == null) {
            returnMap.put("city", "");
        } else {
            returnMap.put("city", city);
        }
        log.info("signature==================" + signature);
        log.info("returnMap====================bankCode:" + bankCode+"userId"+userId);
        Map map = new HashMap();
       /* if (signKeyService.toVerify(signature, returnMap)) {
            map.put("respCode", "00");
            map.put("respMsg", "成功");
            BusAccountBank bank = accountBankService.getOneByUserId(Integer.parseInt(userId));
            if (bank != null) {
                bank.setCardNo(cardNo);
                bank.setAddip(IpUtils.get());
                bank.setBankCode(bankCode);
                bank.setBankName(bankName);
                accountBankService.updateNotNull(bank);
            }
            collect.collect(null,returnMap,userId,null,authAmount,outOrderId,null,21,null,1);
            return map;
        } else {
            map.put("respCode", "01");
            map.put("respMsg", "验签失败");
            collect.collect(null,returnMap,userId,null,authAmount,outOrderId,null,21,null,0);
            return map;
        }*/
       return map;

    }



}
